USE [Monitoring]
GO

--|--------------------------------------------------------------------------------
--| [GetMarkerHashByID] - Insert Procedure Script for MarkerHash
--|--------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id (N'[dbo].[GetMarkerHashByID]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) 
  DROP PROCEDURE [dbo].[GetMarkerHashByID]
GO

CREATE PROCEDURE [dbo].[GetMarkerHashByID]
(
	@Hash datetime
)
AS
	SET NOCOUNT ON

	SELECT
		[Hash],
		[MarkerName],
		[GameName],
		[Login]
	FROM 
MarkerHash
	WHERE
		[Hash] = @Hash
	
GO


--|--------------------------------------------------------------------------------
--| [InsertMarkerHash] - Insert Procedure Script for MarkerHash
--|--------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id (N'[dbo].[InsertMarkerHash]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) 
  DROP PROCEDURE [dbo].[InsertMarkerHash]
GO

CREATE PROCEDURE [dbo].[InsertMarkerHash]
(
	@Hash datetime,
	@MarkerName nvarchar(50),
	@GameName nvarchar(50) = NULL,
	@Login nvarchar(50) = NULL
)
AS
	SET NOCOUNT ON

	INSERT INTO [MarkerHash]
	(
		[Hash],
		[MarkerName],
		[GameName],
		[Login]
	)
	VALUES
	(
		@Hash,
		@MarkerName,
		@GameName,
		@Login
	)

	RETURN @@Error
GO

--|--------------------------------------------------------------------------------
--| [UpdateMarkerHash] - Update Procedure Script for MarkerHash
--|--------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id (N'[dbo].[UpdateMarkerHash]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) 
	DROP PROCEDURE [dbo].[UpdateMarkerHash]
GO

CREATE PROCEDURE [dbo].[UpdateMarkerHash]
(
	@Hash datetime,
	@MarkerName nvarchar(50),
	@GameName nvarchar(50) = NULL,
	@Login nvarchar(50) = NULL
)
AS
	SET NOCOUNT ON
	
	UPDATE [MarkerHash]
	SET
		[Hash] = @Hash,
		[MarkerName] = @MarkerName,
		[GameName] = @GameName,
		[Login] = @Login
	WHERE 
		[Hash] = @Hash

	RETURN @@Error
GO

--|--------------------------------------------------------------------------------
--| [DeleteMarkerHash] - Update Procedure Script for MarkerHash
--|--------------------------------------------------------------------------------
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id (N'[dbo].[DeleteMarkerHash]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) 
	DROP PROCEDURE [dbo].[DeleteMarkerHash]
GO

CREATE PROCEDURE [dbo].[DeleteMarkerHash]
(
	@Hash datetime
)
AS
	SET NOCOUNT ON

	DELETE 
	FROM   [MarkerHash]
	WHERE  
		[Hash] = @Hash

	RETURN @@Error
GO

